# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity study project
File Name: 协程练习.py
Author: kij
Create Date: 2021/3/20
-------------------------------------------------
"""

# import time
# from greenlet import greenlet
#
#
# # 协程 单线程内实现并发效果
# def fun1(arg1, arg2):
# 	print('执行方法一')
# 	g2.switch('func2arg1','func2arg2')
# 	print('执行方法一回来了')
# 	g2.switch()
#
#
# def fun2(arg1, arg2):
# 	print('执行方法二')
# 	g1.switch()
# 	print('方法二回来了')
#
#
# g1 = greenlet(fun1)
# g2 = greenlet(fun2)
# g1.switch('arg1', 'arg2')

from gevent import monkey;monkey.patch_all()
import gevent


def fun1():
	print('执行方法一')
	gevent.sleep(3)
	print('执行方法1')

def fun2():
	print('执行方法二')
	gevent.sleep(5)
	print('执行方法2')




g1 = gevent.spawn(fun1)
g2 = gevent.spawn(fun2)
gevent.joinall([g1,g2])